Skip to content

perf: the panel's conversation list totals each conversation once, so its time grows with the messages, not their square - #20

Merged
BukeLy merged 1 commit into
mainfrom
perf/conversations-linear
Nov 23, 2026
Merged

BukeLy merged 1 commit into
mainfrom
perf/conversations-linear

Conversation

@BukeLy

@BukeLy BukeLy commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

The panel's conversation list takes 0.4 s at 20,000 messages instead of 29.6 s.

Messages Before After
5,000 2,173 ms 95 ms
20,000 29,635 ms 395 ms

One person in that many messages with 50 others, all unread. Postgres 18 in Docker, best of 3 calls.

Test plan

  • uv run pytest -q: 74 passed, 1 skipped (the 73 from before plus one new test).
  • The new test, test_each_conversation_counts_only_what_waits_in_it, checks sides, waiting and waiting_since in two conversations. I broke the query four ways and it failed every time. Without it, two of those breaks passed every test: waiting_since taken from read messages too, and totals joined on true.
  • Same output on mixed data (agents, talk between one person's own agents, three groups, some deliveries read, times out of id order): conversations for 21 people, 118 conversations, returned identical results before and after.
  • uvx ruff@0.17.6 check . and uvx ruff@0.17.6 format --check . pass.

… its time grows with the messages, not their square

conversations ran three subqueries over every side for each message, not for each conversation. With one person in 20,000 messages with 50 others it took 29.6 s; it now takes 0.4 s. At 5,000 messages it went from 2.2 s to 0.1 s. The output is the same. A new test checks waiting, waiting_since and sides per conversation, which no test did: without it, a waiting_since taken from read messages too, or one conversation's totals shown on another, passed every test.
@BukeLy
BukeLy force-pushed the perf/conversations-linear branch from f1a83c6 to 210e507 Compare November 23, 2026 06:38
@BukeLy
BukeLy changed the base branch from feat/usernames-and-remarks to main November 23, 2026 06:38
@BukeLy BukeLy closed this Nov 23, 2026
@BukeLy BukeLy reopened this Nov 23, 2026
@BukeLy
BukeLy marked this pull request as ready for review November 23, 2026 06:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-23T06:46:12.048802Z 210e507 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BukeLy
BukeLy merged commit d03bc30 into main Nov 23, 2026
7 checks passed
@BukeLy
BukeLy deleted the perf/conversations-linear branch November 23, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant